package com.noah.common.utility;

import cn.hutool.core.util.StrUtil;

/**
 * 字符串工具
 * @author noah
 * 2023/9/4 19:37
 */
public class StringUtility extends StrUtil {
    public static String removeStart(String str, String remove) {
        if (!isEmpty(str) && !isEmpty(remove)) {
            return str.startsWith(remove) ? str.substring(remove.length()) : str;
        }
        else {
            return str;
        }
    }

    public static boolean allNotNull(Object... values) {
        if (values == null) {
            return false;
        }
        else {
            for (Object val : values) {
                if (val == null) {
                    return false;
                }
            }
            return true;
        }
    }

    public static String substringBetween(String str, String open, String close) {
        if (allNotNull(str, open, close)) {
            int start = str.indexOf(open);
            if (start != -1) {
                int end = str.indexOf(close, start + open.length());
                if (end != -1) {
                    return str.substring(start + open.length(), end);
                }
            }
        }
        return null;
    }
}
